<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fun()
        {
      var year = window.prompt("请输入你的出生年份");
             var year = 2019-year;
             alert(year);
        }
    </script>
    <div onclick="javascript:fun()">请输入你的出生年份</div>
                          
</body>
</html>